# Set-Alias g Search-Google-Browser
# Set-Alias gg Search-Google-Console
# Set-Alias go Goto-Google-Console-Result

[void][System.Reflection.Assembly]::LoadWithPartialName( "System.Windows.Forms" )
[void][System.Reflection.Assembly]::LoadWithPartialName( "System.Web" )
function Search-Google-Browser()
{
	$url = "http://www.google.com/search"
	$query = [System.Web.HttpUtility]::UrlEncode( [String]::Join( '+', $args ) ).Trim()
	
	if ( $query.EndsWith( "!" ) )
	{
		$query = $query.TrimEnd( "!" ) + ( "&btnI=" + [System.Web.HttpUtility]::UrlEncode( "I'm Feeling Lucky" ) );
	}
	[System.Windows.Forms.Help]::ShowHelp( $null, "$url" + '?' + "hl=en&q=$query" )
}

function Search-Google-Console()
{
	Get-GoogleResults -MaxResults 30 "$args" | Format-Table -AutoSize Index, Title, VisibleUrl, Content
}

function Goto-Google-Console-Result( [int]$resultIndex )
{
	Get-GoogleResults -GotoResult $resultIndex
}
